{{--继承模板--}}
@extends('admin.layouts.common')
@section('content')
    <link rel="stylesheet" type="text/css" href="{{ asset('common/layui-formSelects-master/dist/formSelects-v4.css') }}"/>
    <style>
        div[xm-select-skin=default] dl dd.xm-select-this:not(.xm-dis-disabled) i {
            color: #177ce3;
        }
        .xm-select-parent dl dd.xm-select-this div i {
            color: #177ce3;
        }
        .xm-form-checkbox > i {
            border: 1px solid #177ce3;

        }
        div[xm-select-skin="default"] dl dd:not(.xm-dis-disabled) i {
            border-color: #177ce3;
        }
    </style>
        <blockquote class="layui-elem-quote layui-elem-quote-blue" style="border-left: 5px solid #000000;background: #fff;">
            <span>
                &nbsp;&nbsp;&nbsp;1、《控/方》：意思是 控制器/方法; 例如 Sys/sysList<br/>
                &nbsp;&nbsp;&nbsp;2、图标名称为左侧导航栏目的图标样式，具体可查看<a href="https://www.iconfont.cn/" target="_blank" style="color:#FF0000"> Iconfont </a>图标<br>
                   &nbsp;&nbsp;&nbsp;3、图标写入：<xmp style="display: inline;font-family: '微软雅黑';"><i class="iconfont icon-tianjia2"></i></xmp>
                (只需填入：icon-tianjia2)
            </span>
        </blockquote>
        <br>
        <div class="layui-anim layui-anim-up">
            <form class="layui-form">
                <input type="hidden" name="id" value="{{$info['id']}}">
                <div class="layui-container">
                    <div class="layui-row">
                        <div class="layui-form-item">
                            <label class="layui-form-label">父级</label>
                            <div class="layui-input-block">
                                <select name="pid" lay-verify="required" lay-filter="pid" xm-select="selectId" xm-select-skin="default" xm-select-radio="" xm-select-search="" xm-select-search-type="dl">
                                    <option value="0" {{($info['pid'] == 0)?"selected": ""}}>默认顶级</option>
                                    @foreach($admin_rule as $vo)
                                        <option value="{{$vo['id']}}" {{$vo['id'] == $info['pid'] ?"selected": ""}}>{{$vo['lefthtml']}}{{$vo['title']}}</option>
                                    @endforeach
                                </select>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-inline">
                                <label class="layui-form-label">权限名称</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="title" lay-verify="required" placeholder="请输入权限名称" class="layui-input" value="{{$info['title']}}">
                                </div>
                            </div>
                            <div class="layui-inline">
                                <label class="layui-form-label">控制器/方法</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="href" lay-verify="required" placeholder="请输入控制器/方法" class="layui-input" value="{{$info['href']}}">
                                    {{-- <div class="layui-form-mid layui-word-aux">
                                         <span style="color: red">*</span> 首字母大写，允许2-80字节，允许字母数字
                                     </div>--}}
                                </div>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-inline">
                                <label class="layui-form-label">图标</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="icon" placeholder="请输入图标名称" class="layui-input" value="{{$info['icon']}}">
                                </div>
                            </div>
                            <div class="layui-inline">
                                <label class="layui-form-label">排序</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="sort" value="50" placeholder="请输入排序编号" class="layui-input" value="{{$info['sort']}}">
                                </div>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button type="submit" class="layui-btn layui-btn-blue" lay-submit="" lay-filter="ruleedit">编辑</button>
                                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                            </div>
                        </div>
                    </div>
                </div>
            </form>
        </div>
    <script src="{{asset('layuiadmin/layui/layui.js')}}"></script>
    <script src=" {{ asset('common/layui-formSelects-master/dist/formSelects-v4.js') }}" type="text/javascript" charset="utf-8"></script>
    <script>
        layui.use(['form','layer'], function(){
            var form = layui.form
                ,layer = layui.layer
                ,$ = layui.jquery;
            var _token =  $('meta[name="csrf-token"]').attr('content');
            //监听提交
            form.on('submit(ruleedit)', function(data){
                data.field._token = _token;
                $.post("{{url('admin/auth/ruleedit')}}",data.field,function(res){
                    if(res.code == 1){
                        layer.msg(res.msg,function () {
                            window.location.reload();
                        });
                    }else{
                        layer.msg(res.msg);
                    }
                },'json')
                return false;
            });
        });
    </script>
@endsection